package com.wdm.sms;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.core.env.Environment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.InetAddress;
import java.net.UnknownHostException;

//SpringBoot默认包扫描机制： 从启动类所在包开始，扫描当前包及其子级包下的所有文件。
@Slf4j
// 添加对mapper包扫描
@MapperScan("com.wdm.sms.mapper")
//@ComponentScans(value = {@ComponentScan(basePackages = {"com.wdm.sms.commonutil.config"})})
@SpringBootApplication
public class SmsApplication {

    public static void main(String[] args) {
        log.info("Begin to start Spring Boot com.qm.qfc.wda.wdaservice.Application");
        long startTime = System.currentTimeMillis();
        ConfigurableApplicationContext application = SpringApplication.run(SmsApplication.class, args);
        long endTime = System.currentTimeMillis();
        log.info("End starting Spring Boot com.wdm.sms.SmsApplication, Time used: "+ (endTime - startTime) );
        Environment env = application.getEnvironment();
        try {
            log.info("\n----------------------------------------------------------\n\t" +
                            "应用 '{}' 启动成功! 访问连接:\n\t" +
                            "Swagger文档: http://{}:{}/swagger-ui.html\n\t" +
                            "End starting Spring Boot com.wdm.sms.SmsApplication, Time used: {}s\n\t" +
                            "----------------------------------------------------------",
                    env.getProperty("spring.application.name"),
                    InetAddress.getLocalHost().getHostAddress(),
                    env.getProperty("server.port"),
                    (endTime - startTime)/1000);
        } catch (UnknownHostException e) {
            log.error(e.getMessage());
        }
    }

}
